<% layout('/layouts/default.html', {title: '信用证管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('信用证管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
<!--				<% if(hasPermi('financial:lettercredit:letterCredit:edit')){ %>-->
<!--					<a href="${ctx}/financial/lettercredit/letterCredit/form" class="btn btn-default btnTool" title="${text('新增信用证')}"><i class="fa fa-plus"></i> ${text('新增')}</a>-->
<!--				<% } %>-->
				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${letterCredit}" action="${ctx}/financial/lettercredit/letterCredit/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('编号')}：</label>
					<div class="control-inline">
						<#form:input path="letterCreditCode" maxlength="100" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('服务订单')}：</label>
					<div class="control-inline width-120">
						<#form:select path="serviceOrderId" items="${listServiceOrder}"
						itemLabel="serviceOrderCode" itemValue="serviceOrderId" blankOption="true" class="form-control "/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('客户')}：</label>
					<div class="control-inline width-120">
						<#form:treeselect id="customer" title="${text('客户选择')}"
						path="customer.customerId" labelPath="customer.customerName"
						url="${ctx}/base/customer/customer/treeData" canSelectRoot="true" canSelectParent="true"
						class=" required" allowClear="true"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('国内资方')}：</label>
					<div class="control-inline width-120">
						<#form:select path="investorId" items="${gnzfList}" itemLabel="supplierName" itemValue="supplierId" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('外商')}：</label>
					<div class="control-inline width-120">
						<#form:select path="foreignBusinessmenId" items="${hwzfList}" itemLabel="supplierName" itemValue="supplierId" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('供货外商')}：</label>
					<div class="control-inline width-120">
						<#form:select path="supplierId" items="${supplierList}" itemLabel="supplierName" itemValue="supplierId" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('委托协议')}：</label>
					<div class="control-inline">
						<#form:input path="entrustAgreement" maxlength="100" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('贸易术语')}：</label>
					<div class="control-inline width-120">
						<#form:select path="tradeTerm" dictType="trade_term" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('外贸合同号')}：</label>
					<div class="control-inline">
						<#form:input path="foreignTradeContractNumber" maxlength="100" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('状态')}：</label>
					<div class="control-inline width-120">
						<#form:select path="orderStatus" dictType="letter_credit_status" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('信用证开证日')}：</label>
					<div class="control-inline">
						<#form:input path="letterCreditIssuanceDate_gte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd" data-done="letterCreditIssuanceDate_lte.click()"/>
						&nbsp;-&nbsp;
						<#form:input path="letterCreditIssuanceDate_lte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('信用证号')}：</label>
					<div class="control-inline">
						<#form:input path="letterCreditNumber" maxlength="100" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('信用证到期日')}：</label>
					<div class="control-inline">
						<#form:input path="letterCreditExpiryDate_gte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd" data-done="letterCreditExpiryDate_lte.click()"/>
						&nbsp;-&nbsp;
						<#form:input path="letterCreditExpiryDate_lte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('开证银行')}：</label>
					<div class="control-inline width-120">
						<#form:select path="bank" dictType="bank" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('付款方式')}：</label>
					<div class="control-inline width-120">
						<#form:select path="paymentMethod" dictType="payment_method" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('最晚装船日期')}：</label>
					<div class="control-inline">
						<#form:input path="latestShipmentDate_gte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd" data-done="latestShipmentDate_lte.click()"/>
						&nbsp;-&nbsp;
						<#form:input path="latestShipmentDate_lte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('装运港')}：</label>
					<div class="control-inline width-120">
						<#form:select path="fromPort" dictType="erp_harbor_list" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('目的港')}：</label>
					<div class="control-inline width-120">
						<#form:select path="toPort" dictType="erp_harbor_list" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('币种')}：</label>
					<div class="control-inline width-120">
						<#form:select path="currency" dictType="sys_bizhong" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否预投保')}：</label>
					<div class="control-inline width-120">
						<#form:select path="preInsuredFlag" dictType="sys_yes_no" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('车辆')}：</label>
					<div class="control-inline width-120">
						<#form:select path="letterCreditDetail.carId" items="${tcarList}"
						itemLabel="carName" itemValue="carId" blankOption="true" class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('车型')}：</label>
					<div class="control-inline">
						<#form:input path="letterCreditDetail.model" maxlength="100" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('品牌')}：</label>
					<div class="control-inline width-120">
						<#form:select path="letterCreditDetail.brand" dictType="car_pinpai" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('版型')}：</label>
					<div class="control-inline width-120">
						<#form:select path="letterCreditDetail.area" dictType="car_quyu" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('版本号')}：</label>
					<div class="control-inline">
						<#form:input path="version" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('创建者')}：</label>
					<div class="control-inline width-120">
						<#form:select path="createBy" items="${listUser}"
						itemLabel="userName" itemValue="userCode" blankOption="true" class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('创建时间')}：</label>
					<div class="control-inline">
						<#form:input path="createDate_gte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd" data-done="createDate_lte.click()"/>
						&nbsp;-&nbsp;
						<#form:input path="createDate_lte" readonly="true" maxlength="20" class="form-control laydate width-date"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("编号")}', name:'letterCreditCode', index:'a.letter_credit_code', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/financial/lettercredit/letterCredit/detail?letterCreditId='+row.letterCreditId+'" class="btnList" data-title="${text("编辑信用证")}">'+(val||row.id)+'</a>';
		}},
		{header:'${text("版本号")}', name:'version', index:'a.version', width:150, align:"center"},
		{header:'${text("操作")}', name:'actions', width:140, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('financial:lettercredit:letterCredit:view')){ %>
            actions.push('<a href="${ctx}/financial/lettercredit/letterCredit/detail?letterCreditId='+row.letterCreditId+'" class="btnList" title="${text("查看信用证")}"><i class="fa fa-file-text-o"></i></a>&nbsp;');
			<% } %>

			if(row.orderStatus != "2"){
	<% if(hasPermi('financial:lettercredit:letterCredit:edit')){ %>
			actions.push('<a href="${ctx}/financial/lettercredit/letterCredit/form?letterCreditId='+row.letterCreditId+'" class="btnList" title="${text("编辑信用证")}"><i class="fa fa-pencil"></i></a>&nbsp;');
	<% } %>
	<% if(hasPermi('financial:lettercredit:letterCredit:delete')){ %>
	actions.push('<a href="${ctx}/financial/lettercredit/letterCredit/delete?letterCreditId='+row.letterCreditId+'" class="btnList" title="${text("删除信用证")}" data-confirm="${text("确认要删除该信用证吗？")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
	<% } %>
			}

			return actions.join('');
		}},
		{header:'${text("服务订单")}', name:'serviceOrder.serviceOrderCode', index:'s.service_order_code', width:150, align:"left"},
		{header:'${text("客户")}', name:'customer.customerName', index:'c.customer_name', width:150, align:"center"},
		{header:'${text("国内资方")}', name:'investor.supplierName', index:'e.supplier_name', width:150, align:"center"},
		{header:'${text("外商")}', name:'foreignBusinessmen.supplierName', index:'f.supplier_name', width:150, align:"center"},
		{header:'${text("供应商地址")}', name:'supplierAddress', index:'a.supplier_address', width:150, align:"left"},
		{header:'${text("供货外商")}', name:'supplier.supplierName', index:'d.supplier_name', width:150, align:"center"},
		{header:'${text("委托协议")}', name:'entrustAgreement', index:'a.entrust_agreement', width:150, align:"left"},
		{header:'${text("贸易术语")}', name:'tradeTerm', index:'a.trade_term', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('trade_term')}, val, '${text("未知")}', true);
		}},
		{header:'${text("外贸合同号")}', name:'foreignTradeContractNumber', index:'a.foreign_trade_contract_number', width:150, align:"left"},
		{header:'${text("状态")}', name:'orderStatus', index:'a.order_status', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('letter_credit_status')}, val, '${text("未知")}', true);
		}},
		{header:'${text("信用证开证日")}', name:'letterCreditIssuanceDate', index:'a.letter_credit_issuance_date', width:150, align:"center"},
		{header:'${text("信用证号")}', name:'letterCreditNumber', index:'a.letter_credit_number', width:150, align:"left"},
		{header:'${text("信用证到期日")}', name:'letterCreditExpiryDate', index:'a.letter_credit_expiry_date', width:150, align:"center"},
		{header:'${text("开证比例")}', name:'ratio', index:'a.ratio', width:150, align:"left"},
		{header:'${text("开证银行")}', name:'bank', index:'a.bank', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('bank')}, val, '${text("未知")}', true);
		}},
		{header:'${text("信用证总金额")}', name:'totalAmount', index:'a.total_amount', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text("付款方式")}', name:'paymentMethod', index:'a.payment_method', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('payment_method')}, val, '${text("未知")}', true);
		}},
		{header:'${text("最晚装船日期")}', name:'latestShipmentDate', index:'a.latest_shipment_date', width:150, align:"center"},
		{header:'${text("装运港")}', name:'fromPort', index:'a.from_port', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('erp_harbor_list')}, val, '${text("未知")}', true);
		}},
		{header:'${text("目的港")}', name:'toPort', index:'a.to_port', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('erp_harbor_list')}, val, '${text("未知")}', true);
		}},
		{header:'${text("币种")}', name:'currency', index:'a.currency', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('sys_bizhong')}, val, '${text("未知")}', true);
		}},
		{header:'${text("是否预投保")}', name:'preInsuredFlag', index:'a.pre_insured_flag', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('sys_yes_no')}, val, '${text("未知")}', true);
		}},
		{header:'${text("备注信息")}', name:'remarks', index:'a.remarks', width:150, align:"left"},
		{header:'${text("创建者")}', name:'createBy', index:'a.create_by', width:150, align:"left"},
		{header:'${text("创建时间")}', name:'createDate', index:'a.create_date', width:150, align:"center"},
	],
	frozenCols: true,
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>